package com.wallet.trans.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ResultCodeEnum {

    PASS(200,"操作成功"),
    SYSTEM_ERROR(5000,"系统错误"),
    PARAMS_ERROR(4001,"参数异常"),
    MESSAGE_REPEAT_ERROR(4002,"已消费mq"),
    SERIALNo_REPEAT_ERROR(4003,"已处理交易流水号"),
    OPERATION_ERROR(5004,"操作失败"),
    ADDRESS_ERROR(6001,"地址找不到对应的商户"),
    SYMBOL_ERROR(6002,"未知的币种"),
    SENDTO_ERROR(6003,"出金失败"),
    ;

    private final Integer code;

    private final String message;

    ResultCodeEnum(Integer code, String message){
        this.code = code;
        this.message = message;
    }


    public static ResultCodeEnum getInstance(final Integer code) {
        for(ResultCodeEnum side : values()) {
            if(Objects.equals(side.getCode(), code)) {
                return side;
            }
        }
        return ResultCodeEnum.OPERATION_ERROR;
    }
}
